package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class conllectionIterator {
	/**
	 * collections List ,Set, Map manipulate
	 */
	public static void print(Collection<? extends Object> collections) {
		Iterator it = collections.iterator();

		while (it.hasNext()) {
			Object element = it.next();
			System.out.println(element);
		}
	}

	public static void main(String[] args) {
		List<String> list = new ArrayList<String>();
		list.add("name");
		list.add("name");
		list.add("password");
		print(list);
		// name name password
		Set<String> set = new HashSet<String>();
		set.add("name");
		set.add("name");
		set.add("password"); 
		print(set);
		// name password
		Map<Integer, String> map = new HashMap<Integer, String>();
		map.put(1, "name");
		map.put(2, "name");
		map.put(3, "password");
		map.put(3, "password");

		print(map.entrySet());
		// 1=name 2=name 3 password
	}
}
